/*
 * 
 * Created on Jul 12, 2005
 */
package com.wgo.precise.client.ui.view.util;

import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;

import com.wgo.precise.client.ui.model.NodeParent;
import com.wgo.precise.client.ui.model.facade.ILabelProviderItem;


public class ModelItemLabelProvider extends LabelProvider {

    
    @Override
	public String getText(Object obj) {
        if ( obj instanceof ILabelProviderItem ) {
            return ((ILabelProviderItem)obj).getText();
        }
		return obj.toString();
	}
    
	@Override
	public Image getImage(Object obj) {
        if ( obj instanceof ILabelProviderItem ) {
            return ((ILabelProviderItem)obj).getImage();
        }
        //could probalby delete soon? or change to question-mark-image
		String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
		if (obj instanceof NodeParent){
            NodeParent tn = (NodeParent)obj;
            if (tn.hasChildren()) {
               imageKey = ISharedImages.IMG_OBJ_FOLDER;
            }
        }
		return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
	}
}